package com.example.axgame;

import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import fr.axgame.fragments.ArenaFragment;
import fr.axgame.fragments.CharacterFragment;
import fr.axgame.fragments.MapFragment;
import fr.axgame.listeners.TabListener;

public class Start extends Activity {

    private ArenaFragment arenaFragment = new ArenaFragment();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        // getMenuInflater().inflate(R.menu.start, menu);

        // Setup action bar for tabs
        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);

        Tab tab = actionBar.newTab().setText(R.string.arena)
                .setTabListener(new TabListener<ArenaFragment>(this, "Arene", ArenaFragment.class));
        actionBar.addTab(tab);

        tab = actionBar.newTab().setText(R.string.character)
                .setTabListener(new TabListener<CharacterFragment>(this, "Personnage", CharacterFragment.class));
        actionBar.addTab(tab);

        tab = actionBar.newTab().setText(R.string.map)
                .setTabListener(new TabListener<MapFragment>(this, "Carte", MapFragment.class));
        actionBar.addTab(tab);

        return true;
    }

    public void fight(View view) {
        TextView lifeHeroTV = (TextView) findViewById(R.id.lifeHeroTextView);
        TextView lifeFoeTV = (TextView) findViewById(R.id.lifeFoeTextView);
        arenaFragment.fight(lifeHeroTV, lifeFoeTV);
    }
}
